/*
 * WageEmployee.java
 *
 * This class is a derived class of class Employee and implements the Overtime
 * interface. It is used to store the details of daily waged employees and
 * display the same.
 *
 * 
 */

package com.javacore.day6.maxsoft3;

/**
 * WageEmployee class inherits Employee class and implements Overtime interface.
 * @author 
 */
public class WageEmployee extends Employee implements Overtime {
    
    /** Creates a new instance of WageEmployee. */
    public WageEmployee() {
    }
    
    /**
     * Creates a new instance of WageEmployee and stores details
     * in the instance variables.
     * @param name Parameter containing the name of the employee
     * @param rate Parameter containing the value of rate per hour
     * @param hours Parameter containing the number of hours an employee has worked
     */
    public WageEmployee(String name, double rate, int hours) {
        super(name);
        this.rate = rate;
        this.hours = hours;
    }
    
    /**
     * Method to calculate over time pay.
     * @return Returns the calculated overtime payment that an employee will receive
     */
    public double calculateOvertime() {
        return (this.rate * this.hours) * (this.OVERTIME_PAY_PERCENT / 100);
    }
    
    /**
     * Method to display the salary details.
     */
    void displayDetails() {
        System.out.printf("\nEmployee Name: %s ",this.name);
        
        // Employees who worked more than 10 hours get over time pay
        if(this.hours > 10) {
            System.out.printf("\nEmployee salary: %.2f ",
                    (this.rate * this.hours) + this.calculateOvertime());
        } else {
            System.out.printf("\nEmployee salary: %.2f ",
                    (this.rate * this.hours));
        }
    }
    
    /**
     * Instance variable rate to store rate for one hour.
     */
    double rate;
    
    /**
     * Instance variable hours to store the employee's working hours.
     */
    int hours;
}
